fn main() {}
fn solution(s: &str) -> String {
    let (int, dec) = match s.split_once('.') {
        Some((int, dec)) => (int, Some(dec)),
        None => (s, None),
    };
    let pre = int.trim_start_matches('0');
    let pre = if pre.is_empty() { "0" } else { pre };
    let v1: Vec<char> = pre.chars().rev().collect();
    println!("v1 is {:?}", v1);
    let mut v2: Vec<char> = vec![];
    for (index, item) in v1.iter().enumerate() {
        if index != 0 && index % 3 == 0 {
            v2.push(',');
        }
        v2.push(*item);
    }
    v2.reverse();
    println!("v2 is {:?}", v2);
    match dec {
        Some(info) => format!("{}.{}",String::from_iter(v2), info),
        None => String::from_iter(v2).to_string(),
    }
}
#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn test_solution() {
        assert_eq!(solution("123"), "123");
        assert_eq!(solution("111.222"), "111.222");
        assert_eq!(solution("00111.222"), "111.222");
        assert_eq!(solution("123456"), "123,456");
        // assert_eq!(solution("0000123456789.99"), "123,456,789.99");
        // assert_eq!(solution("987654321"), "987,654,321");
    }
}
